﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml.Linq;
using HigLabo.Net.Extensions;

namespace HigLabo.Net.Twitter
{
    /// <summary>
    /// 
    /// </summary>
    public class SavedSearch : ResponseObject
    {
        private String _Name = null;
        private String _Postion = null;
        private DateTimeOffset _CreatedAt = DateTimeOffset.Now;
        private Int64 _ID = 0;
        private String _Query = null;

        /// <summary>
        /// 
        /// </summary>
        public String Name
        {
            get { return _Name; }
            set { _Name = value; }
        }
        /// <summary>
        /// 
        /// </summary>
        public String Postion
        {
            get { return _Postion; }
            set { _Postion = value; }
        }
        /// <summary>
        /// 
        /// </summary>
        public DateTimeOffset CreatedAt
        {
            get { return _CreatedAt; }
            set { _CreatedAt = value; }
        }
        /// <summary>
        /// 
        /// </summary>
        public Int64 ID
        {
            get { return _ID; }
            set { _ID = value; }
        }
        /// <summary>
        /// 
        /// </summary>
        public String Query
        {
            get { return _Query; }
            set { _Query = value; }
        }
        /// <summary>
        /// 
        /// </summary>
        public String IDStr { set; get; }


        /// <summary>
        /// 
        /// </summary>
        /// <param name="jsonText"></param>
        public SavedSearch(String jsonText)
        {
            this.SetProperty(jsonText);
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="jsonText"></param>
        public override void SetProperty(string jsonText)
        {
            var d = this.SetData(jsonText);
            
            this.Name = d.ToString("name");
            this.Postion = d.ToString("position");
            this.CreatedAt = d.CastToDateTimeOffset("created_at") ?? this.CreatedAt;
            this.ID = d.ToInt64("id") ?? this.ID;
            this.Query = d.ToString("query");
            this.IDStr = d.ToString("id_str");
        }
    }
}
